package yxy.game.pm2.command.niubee;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.NiuBeeMessage;
import yxy.game.pm2.module.niubee.NiuBeeHandle;

/** 神器 神器界面 */
@MessageType(proto = Command.NiuBee, classtype = NiuBeeMessage.NiuBeeRequest.class)
public class CMD_NiuBee extends Command<NiuBeeMessage.NiuBeeRequest> {

	@Override
	public void execute(MessageSource messageSource, NiuBeeMessage.NiuBeeRequest request) {
		String playerCode = messageSource.getTag();

		NiuBeeMessage.NiuBeeResponse.Builder response = NiuBeeMessage.NiuBeeResponse.newBuilder();

		new NiuBeeHandle().info(playerCode, response);
		send(messageSource, response, Result.Success);
	}

	private void send(MessageSource messageSource, NiuBeeMessage.NiuBeeResponse.Builder response, Result result) {
		response.setResult(result.packResult());
		MessageEmitterHandler.getInstance().send(messageSource, response.build());
	}
}